--[[
* 能量变更后
*]]
---@class BuffEffect68 : BaseBuffEffect
BuffEffect68 = ClientFight.CreateClass("BuffEffect68", ClientFight.BaseBuffEffect)
local t = BuffEffect68
---@param fight Fight
---@param buff FighterBuff
local BUFF_EFFECT_PARAMETERS_68_ = "BUFF_EFFECT_PARAMETERS_68_";
function t:action(fight, buff, ...)
    ---fighter, skillId, energy,reason
    local parameters = {...};
    local fightResult = parameters[3];
    if (fightResult.getDamageType() ~= SkillDamageTypeEnum.ENERGY) then
        return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
    end
    local energy = fightResultdamage;
    energy = math.abs(energy);
    local old = buffeffectParams[BUFF_EFFECT_PARAMETERS_68_] or  0;
    energy = energy + old;
    local step = buff.buffBeanf_BuffEffectValue[1];
    if (energy < step) then
        buff.effectParams[BUFF_EFFECT_PARAMETERS_68_] = energy;
        return IBuffEffect.FAIL;
    end
    local triggerNum = energy / step;--可触发次数
    energy = energy - triggerNum * step;--剩余能量
    buff.effectParams[BUFF_EFFECT_PARAMETERS_68_] = energy;
    if (FighterStateEnum.is(buff.target, FighterStateEnum.BAN_HEAL)) then
        return IBuffEffect.FAIL;
    end
    if (buff.target:isDie()) then
        return IBuffEffect.FAIL;
    end
    local addHpPer = buff.buffBeanf_BuffEffectValue[2];

    local addHpValue = (FighterAttributeManager.getFightAttr(buff.target, FighterAttributeEnum.HP) * Utils.toRatio(addHpPer * triggerNum));

    DamageManager.setFighterHp(fight, buff.target, buff.target, nil, DamageResultTypeEnum.HEAL, addHpValue, buff.targethp + addHpValue, true, false, true);

    SkillRoleMgr.savePathFile("[" .. fightframe .. "][EFFECT]Fighter " .. buff.targetfighterId .. " Buff"
            .. buffmodelId .. " 触发每消耗 " .. step .. "点能量 恢复血量万分之 " .. addHpPer .. " , 总恢复血量值= " .. addHpValue);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
end

t.New()